package com.wyy.controller;

import com.wyy.pojo.model.CommentQuery;
import com.wyy.response.CommonReturnType;
import com.wyy.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @program: gytcb
 * @author: 吴磊
 * @create: 2021-06-08 18:21
 */
@RestController
public class CommentController {
    @Autowired
    private CommentService commentService;

    /**
     * 获取所有的评论
     *
     * @param commentQuery
     * @return
     */
    @RequestMapping(value = "/getAllComment", method = RequestMethod.POST)
    public CommonReturnType getAllComment(@RequestBody CommentQuery commentQuery) {
        Map<String, Object> map = commentService.getAllComment(commentQuery);
        return CommonReturnType.create(map);
    }

    /**
     * 通过评论Id删除评论
     *
     * @param commentId
     * @return
     */
    @RequestMapping(value = "/deleteCommentById", method = RequestMethod.POST)
    public CommonReturnType deleteCommentById(@RequestBody String commentId) {
        commentService.deleteCommentById(commentId);
        return CommonReturnType.create(null);
    }
}
